package Thread;

public class ThreadTest2_2 {
    public static void main(String[] args) {
        //1、直接创建Runnable接口的匿名内部类对象形式（任务对象）
        Runnable target = new Runnable() {
            @Override
            public void run() {
                for (int i = 1;i<=5;i++){
                    System.out.println("子线程1输出"+i);
                }
            }
        };
        new Thread(target).start();
        //简化形式1

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1;i<=5;i++){
                    System.out.println("子线程2输出"+i);
                }
            }
        }).start();

        //简化形式2
        new Thread(() ->{
            for (int i = 1;i<=5;i++){
                System.out.println("子线程3输出===="+i);
            }
        }

        ).start();


        for (int i =1;i<=5;i++){
            System.out.println("主线程main方法输出"+i);
        }
    }
}
